{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 日期：2022-9-14"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建有序数值（创建自然数）\n",
    "range(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,5)) #产生了5-0个值，默认从0开始  注：0（start）5(stop)每次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(2, 5)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(2,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 3, 4]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list (range(2,5))#产生了5-2个值，start=2 stop=5 每一次增长1个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(1, 10, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(1,10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 7]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(1,10,3))#start=2 stop=5 stpe=3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://nfu.edu.cn/xxyw/index0.htm\n",
      "该次停留 6 秒\n",
      "https://nfu.edu.cn/xxyw/index1.htm\n",
      "该次停留 9 秒\n",
      "https://nfu.edu.cn/xxyw/index2.htm\n",
      "该次停留 4 秒\n",
      "https://nfu.edu.cn/xxyw/index3.htm\n",
      "该次停留 2 秒\n",
      "https://nfu.edu.cn/xxyw/index4.htm\n",
      "该次停留 3 秒\n",
      "https://nfu.edu.cn/xxyw/index5.htm\n",
      "该次停留 4 秒\n",
      "https://nfu.edu.cn/xxyw/index6.htm\n",
      "该次停留 9 秒\n",
      "https://nfu.edu.cn/xxyw/index7.htm\n",
      "该次停留 4 秒\n",
      "https://nfu.edu.cn/xxyw/index8.htm\n",
      "该次停留 1 秒\n",
      "https://nfu.edu.cn/xxyw/index9.htm\n",
      "该次停留 2 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习：快速生成某个网站的所有页码的URL队列\n",
    "import random\n",
    "import time\n",
    "南方学院学校要闻=\"https://nfu.edu.cn/xxyw/index\"\n",
    "页面后缀=\".htm\"\n",
    "page=10\n",
    "\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻+str(i)+页面后缀) #字符串拼接\n",
    "    random_num=random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 总结，for+range  for可以执行循环，range决定了循环体的执行次数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 本周内容  \n",
    "\n",
    "> 1.random 模块  \n",
    ">> 1.random.random():生成0-1之间的 伪随机数（浮点型数）  \n",
    ">> 2.random.randint(a,b):生成a-b之间的 随机整数（整数）  \n",
    ">> 3.random.chioce():随机生成一个序列中的值（非空）  \n",
    "\n",
    "\n",
    "> 2.time模块\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 1. random\n",
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.34624407314216565"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " random.random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function random:\n",
      "\n",
      "random(...) method of random.Random instance\n",
      "    random() -> x in the interval [0, 1).\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.random)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method randint in module random:\n",
      "\n",
      "randint(a, b) method of random.Random instance\n",
      "    Return random integer in range [a, b], including both end points.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "## 2.randint\n",
    "help(random.randint)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(1,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "5\n",
      "4\n",
      "3\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 3.random.choice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on method choice in module random:\n",
      "\n",
      "choice(seq) method of random.Random instance\n",
      "    Choose a random element from a non-empty sequence.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(random.choice)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'陈'"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.choice(['黄斐珍','陈'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sleep in module time:\n",
      "\n",
      "sleep(...)\n",
      "    sleep(seconds)\n",
      "    \n",
      "    Delay execution for a given number of seconds.  The argument may be\n",
      "    a floating point number for subsecond precision.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(time.sleep)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello\")\n",
    "time.sleep(3)\n",
    "print(\"world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  3.课本实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "import time,random\n",
    "\n",
    "odds=[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "for i in range\n",
    "second=datetime.datetime.today().second"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 bottles 在啤酒墙上\n",
      "99 bottles 啤酒\n",
      "拿一瓶走\n",
      "98 bottles 在啤酒墙上\n",
      "\n",
      "98 bottles 在啤酒墙上\n",
      "98 bottles 啤酒\n",
      "拿一瓶走\n",
      "97 bottles 在啤酒墙上\n",
      "\n",
      "97 bottles 在啤酒墙上\n",
      "97 bottles 啤酒\n",
      "拿一瓶走\n",
      "96 bottles 在啤酒墙上\n",
      "\n",
      "96 bottles 在啤酒墙上\n",
      "96 bottles 啤酒\n",
      "拿一瓶走\n",
      "95 bottles 在啤酒墙上\n",
      "\n",
      "95 bottles 在啤酒墙上\n",
      "95 bottles 啤酒\n",
      "拿一瓶走\n",
      "94 bottles 在啤酒墙上\n",
      "\n",
      "94 bottles 在啤酒墙上\n",
      "94 bottles 啤酒\n",
      "拿一瓶走\n",
      "93 bottles 在啤酒墙上\n",
      "\n",
      "93 bottles 在啤酒墙上\n",
      "93 bottles 啤酒\n",
      "拿一瓶走\n",
      "92 bottles 在啤酒墙上\n",
      "\n",
      "92 bottles 在啤酒墙上\n",
      "92 bottles 啤酒\n",
      "拿一瓶走\n",
      "91 bottles 在啤酒墙上\n",
      "\n",
      "91 bottles 在啤酒墙上\n",
      "91 bottles 啤酒\n",
      "拿一瓶走\n",
      "90 bottles 在啤酒墙上\n",
      "\n",
      "90 bottles 在啤酒墙上\n",
      "90 bottles 啤酒\n",
      "拿一瓶走\n",
      "89 bottles 在啤酒墙上\n",
      "\n",
      "89 bottles 在啤酒墙上\n",
      "89 bottles 啤酒\n",
      "拿一瓶走\n",
      "88 bottles 在啤酒墙上\n",
      "\n",
      "88 bottles 在啤酒墙上\n",
      "88 bottles 啤酒\n",
      "拿一瓶走\n",
      "87 bottles 在啤酒墙上\n",
      "\n",
      "87 bottles 在啤酒墙上\n",
      "87 bottles 啤酒\n",
      "拿一瓶走\n",
      "86 bottles 在啤酒墙上\n",
      "\n",
      "86 bottles 在啤酒墙上\n",
      "86 bottles 啤酒\n",
      "拿一瓶走\n",
      "85 bottles 在啤酒墙上\n",
      "\n",
      "85 bottles 在啤酒墙上\n",
      "85 bottles 啤酒\n",
      "拿一瓶走\n",
      "84 bottles 在啤酒墙上\n",
      "\n",
      "84 bottles 在啤酒墙上\n",
      "84 bottles 啤酒\n",
      "拿一瓶走\n",
      "83 bottles 在啤酒墙上\n",
      "\n",
      "83 bottles 在啤酒墙上\n",
      "83 bottles 啤酒\n",
      "拿一瓶走\n",
      "82 bottles 在啤酒墙上\n",
      "\n",
      "82 bottles 在啤酒墙上\n",
      "82 bottles 啤酒\n",
      "拿一瓶走\n",
      "81 bottles 在啤酒墙上\n",
      "\n",
      "81 bottles 在啤酒墙上\n",
      "81 bottles 啤酒\n",
      "拿一瓶走\n",
      "80 bottles 在啤酒墙上\n",
      "\n",
      "80 bottles 在啤酒墙上\n",
      "80 bottles 啤酒\n",
      "拿一瓶走\n",
      "79 bottles 在啤酒墙上\n",
      "\n",
      "79 bottles 在啤酒墙上\n",
      "79 bottles 啤酒\n",
      "拿一瓶走\n",
      "78 bottles 在啤酒墙上\n",
      "\n",
      "78 bottles 在啤酒墙上\n",
      "78 bottles 啤酒\n",
      "拿一瓶走\n",
      "77 bottles 在啤酒墙上\n",
      "\n",
      "77 bottles 在啤酒墙上\n",
      "77 bottles 啤酒\n",
      "拿一瓶走\n",
      "76 bottles 在啤酒墙上\n",
      "\n",
      "76 bottles 在啤酒墙上\n",
      "76 bottles 啤酒\n",
      "拿一瓶走\n",
      "75 bottles 在啤酒墙上\n",
      "\n",
      "75 bottles 在啤酒墙上\n",
      "75 bottles 啤酒\n",
      "拿一瓶走\n",
      "74 bottles 在啤酒墙上\n",
      "\n",
      "74 bottles 在啤酒墙上\n",
      "74 bottles 啤酒\n",
      "拿一瓶走\n",
      "73 bottles 在啤酒墙上\n",
      "\n",
      "73 bottles 在啤酒墙上\n",
      "73 bottles 啤酒\n",
      "拿一瓶走\n",
      "72 bottles 在啤酒墙上\n",
      "\n",
      "72 bottles 在啤酒墙上\n",
      "72 bottles 啤酒\n",
      "拿一瓶走\n",
      "71 bottles 在啤酒墙上\n",
      "\n",
      "71 bottles 在啤酒墙上\n",
      "71 bottles 啤酒\n",
      "拿一瓶走\n",
      "70 bottles 在啤酒墙上\n",
      "\n",
      "70 bottles 在啤酒墙上\n",
      "70 bottles 啤酒\n",
      "拿一瓶走\n",
      "69 bottles 在啤酒墙上\n",
      "\n",
      "69 bottles 在啤酒墙上\n",
      "69 bottles 啤酒\n",
      "拿一瓶走\n",
      "68 bottles 在啤酒墙上\n",
      "\n",
      "68 bottles 在啤酒墙上\n",
      "68 bottles 啤酒\n",
      "拿一瓶走\n",
      "67 bottles 在啤酒墙上\n",
      "\n",
      "67 bottles 在啤酒墙上\n",
      "67 bottles 啤酒\n",
      "拿一瓶走\n",
      "66 bottles 在啤酒墙上\n",
      "\n",
      "66 bottles 在啤酒墙上\n",
      "66 bottles 啤酒\n",
      "拿一瓶走\n",
      "65 bottles 在啤酒墙上\n",
      "\n",
      "65 bottles 在啤酒墙上\n",
      "65 bottles 啤酒\n",
      "拿一瓶走\n",
      "64 bottles 在啤酒墙上\n",
      "\n",
      "64 bottles 在啤酒墙上\n",
      "64 bottles 啤酒\n",
      "拿一瓶走\n",
      "63 bottles 在啤酒墙上\n",
      "\n",
      "63 bottles 在啤酒墙上\n",
      "63 bottles 啤酒\n",
      "拿一瓶走\n",
      "62 bottles 在啤酒墙上\n",
      "\n",
      "62 bottles 在啤酒墙上\n",
      "62 bottles 啤酒\n",
      "拿一瓶走\n",
      "61 bottles 在啤酒墙上\n",
      "\n",
      "61 bottles 在啤酒墙上\n",
      "61 bottles 啤酒\n",
      "拿一瓶走\n",
      "60 bottles 在啤酒墙上\n",
      "\n",
      "60 bottles 在啤酒墙上\n",
      "60 bottles 啤酒\n",
      "拿一瓶走\n",
      "59 bottles 在啤酒墙上\n",
      "\n",
      "59 bottles 在啤酒墙上\n",
      "59 bottles 啤酒\n",
      "拿一瓶走\n",
      "58 bottles 在啤酒墙上\n",
      "\n",
      "58 bottles 在啤酒墙上\n",
      "58 bottles 啤酒\n",
      "拿一瓶走\n",
      "57 bottles 在啤酒墙上\n",
      "\n",
      "57 bottles 在啤酒墙上\n",
      "57 bottles 啤酒\n",
      "拿一瓶走\n",
      "56 bottles 在啤酒墙上\n",
      "\n",
      "56 bottles 在啤酒墙上\n",
      "56 bottles 啤酒\n",
      "拿一瓶走\n",
      "55 bottles 在啤酒墙上\n",
      "\n",
      "55 bottles 在啤酒墙上\n",
      "55 bottles 啤酒\n",
      "拿一瓶走\n",
      "54 bottles 在啤酒墙上\n",
      "\n",
      "54 bottles 在啤酒墙上\n",
      "54 bottles 啤酒\n",
      "拿一瓶走\n",
      "53 bottles 在啤酒墙上\n",
      "\n",
      "53 bottles 在啤酒墙上\n",
      "53 bottles 啤酒\n",
      "拿一瓶走\n",
      "52 bottles 在啤酒墙上\n",
      "\n",
      "52 bottles 在啤酒墙上\n",
      "52 bottles 啤酒\n",
      "拿一瓶走\n",
      "51 bottles 在啤酒墙上\n",
      "\n",
      "51 bottles 在啤酒墙上\n",
      "51 bottles 啤酒\n",
      "拿一瓶走\n",
      "50 bottles 在啤酒墙上\n",
      "\n",
      "50 bottles 在啤酒墙上\n",
      "50 bottles 啤酒\n",
      "拿一瓶走\n",
      "49 bottles 在啤酒墙上\n",
      "\n",
      "49 bottles 在啤酒墙上\n",
      "49 bottles 啤酒\n",
      "拿一瓶走\n",
      "48 bottles 在啤酒墙上\n",
      "\n",
      "48 bottles 在啤酒墙上\n",
      "48 bottles 啤酒\n",
      "拿一瓶走\n",
      "47 bottles 在啤酒墙上\n",
      "\n",
      "47 bottles 在啤酒墙上\n",
      "47 bottles 啤酒\n",
      "拿一瓶走\n",
      "46 bottles 在啤酒墙上\n",
      "\n",
      "46 bottles 在啤酒墙上\n",
      "46 bottles 啤酒\n",
      "拿一瓶走\n",
      "45 bottles 在啤酒墙上\n",
      "\n",
      "45 bottles 在啤酒墙上\n",
      "45 bottles 啤酒\n",
      "拿一瓶走\n",
      "44 bottles 在啤酒墙上\n",
      "\n",
      "44 bottles 在啤酒墙上\n",
      "44 bottles 啤酒\n",
      "拿一瓶走\n",
      "43 bottles 在啤酒墙上\n",
      "\n",
      "43 bottles 在啤酒墙上\n",
      "43 bottles 啤酒\n",
      "拿一瓶走\n",
      "42 bottles 在啤酒墙上\n",
      "\n",
      "42 bottles 在啤酒墙上\n",
      "42 bottles 啤酒\n",
      "拿一瓶走\n",
      "41 bottles 在啤酒墙上\n",
      "\n",
      "41 bottles 在啤酒墙上\n",
      "41 bottles 啤酒\n",
      "拿一瓶走\n",
      "40 bottles 在啤酒墙上\n",
      "\n",
      "40 bottles 在啤酒墙上\n",
      "40 bottles 啤酒\n",
      "拿一瓶走\n",
      "39 bottles 在啤酒墙上\n",
      "\n",
      "39 bottles 在啤酒墙上\n",
      "39 bottles 啤酒\n",
      "拿一瓶走\n",
      "38 bottles 在啤酒墙上\n",
      "\n",
      "38 bottles 在啤酒墙上\n",
      "38 bottles 啤酒\n",
      "拿一瓶走\n",
      "37 bottles 在啤酒墙上\n",
      "\n",
      "37 bottles 在啤酒墙上\n",
      "37 bottles 啤酒\n",
      "拿一瓶走\n",
      "36 bottles 在啤酒墙上\n",
      "\n",
      "36 bottles 在啤酒墙上\n",
      "36 bottles 啤酒\n",
      "拿一瓶走\n",
      "35 bottles 在啤酒墙上\n",
      "\n",
      "35 bottles 在啤酒墙上\n",
      "35 bottles 啤酒\n",
      "拿一瓶走\n",
      "34 bottles 在啤酒墙上\n",
      "\n",
      "34 bottles 在啤酒墙上\n",
      "34 bottles 啤酒\n",
      "拿一瓶走\n",
      "33 bottles 在啤酒墙上\n",
      "\n",
      "33 bottles 在啤酒墙上\n",
      "33 bottles 啤酒\n",
      "拿一瓶走\n",
      "32 bottles 在啤酒墙上\n",
      "\n",
      "32 bottles 在啤酒墙上\n",
      "32 bottles 啤酒\n",
      "拿一瓶走\n",
      "31 bottles 在啤酒墙上\n",
      "\n",
      "31 bottles 在啤酒墙上\n",
      "31 bottles 啤酒\n",
      "拿一瓶走\n",
      "30 bottles 在啤酒墙上\n",
      "\n",
      "30 bottles 在啤酒墙上\n",
      "30 bottles 啤酒\n",
      "拿一瓶走\n",
      "29 bottles 在啤酒墙上\n",
      "\n",
      "29 bottles 在啤酒墙上\n",
      "29 bottles 啤酒\n",
      "拿一瓶走\n",
      "28 bottles 在啤酒墙上\n",
      "\n",
      "28 bottles 在啤酒墙上\n",
      "28 bottles 啤酒\n",
      "拿一瓶走\n",
      "27 bottles 在啤酒墙上\n",
      "\n",
      "27 bottles 在啤酒墙上\n",
      "27 bottles 啤酒\n",
      "拿一瓶走\n",
      "26 bottles 在啤酒墙上\n",
      "\n",
      "26 bottles 在啤酒墙上\n",
      "26 bottles 啤酒\n",
      "拿一瓶走\n",
      "25 bottles 在啤酒墙上\n",
      "\n",
      "25 bottles 在啤酒墙上\n",
      "25 bottles 啤酒\n",
      "拿一瓶走\n",
      "24 bottles 在啤酒墙上\n",
      "\n",
      "24 bottles 在啤酒墙上\n",
      "24 bottles 啤酒\n",
      "拿一瓶走\n",
      "23 bottles 在啤酒墙上\n",
      "\n",
      "23 bottles 在啤酒墙上\n",
      "23 bottles 啤酒\n",
      "拿一瓶走\n",
      "22 bottles 在啤酒墙上\n",
      "\n",
      "22 bottles 在啤酒墙上\n",
      "22 bottles 啤酒\n",
      "拿一瓶走\n",
      "21 bottles 在啤酒墙上\n",
      "\n",
      "21 bottles 在啤酒墙上\n",
      "21 bottles 啤酒\n",
      "拿一瓶走\n",
      "20 bottles 在啤酒墙上\n",
      "\n",
      "20 bottles 在啤酒墙上\n",
      "20 bottles 啤酒\n",
      "拿一瓶走\n",
      "19 bottles 在啤酒墙上\n",
      "\n",
      "19 bottles 在啤酒墙上\n",
      "19 bottles 啤酒\n",
      "拿一瓶走\n",
      "18 bottles 在啤酒墙上\n",
      "\n",
      "18 bottles 在啤酒墙上\n",
      "18 bottles 啤酒\n",
      "拿一瓶走\n",
      "17 bottles 在啤酒墙上\n",
      "\n",
      "17 bottles 在啤酒墙上\n",
      "17 bottles 啤酒\n",
      "拿一瓶走\n",
      "16 bottles 在啤酒墙上\n",
      "\n",
      "16 bottles 在啤酒墙上\n",
      "16 bottles 啤酒\n",
      "拿一瓶走\n",
      "15 bottles 在啤酒墙上\n",
      "\n",
      "15 bottles 在啤酒墙上\n",
      "15 bottles 啤酒\n",
      "拿一瓶走\n",
      "14 bottles 在啤酒墙上\n",
      "\n",
      "14 bottles 在啤酒墙上\n",
      "14 bottles 啤酒\n",
      "拿一瓶走\n",
      "13 bottles 在啤酒墙上\n",
      "\n",
      "13 bottles 在啤酒墙上\n",
      "13 bottles 啤酒\n",
      "拿一瓶走\n",
      "12 bottles 在啤酒墙上\n",
      "\n",
      "12 bottles 在啤酒墙上\n",
      "12 bottles 啤酒\n",
      "拿一瓶走\n",
      "11 bottles 在啤酒墙上\n",
      "\n",
      "11 bottles 在啤酒墙上\n",
      "11 bottles 啤酒\n",
      "拿一瓶走\n",
      "10 bottles 在啤酒墙上\n",
      "\n",
      "10 bottles 在啤酒墙上\n",
      "10 bottles 啤酒\n",
      "拿一瓶走\n",
      "9 bottles 在啤酒墙上\n",
      "\n",
      "9 bottles 在啤酒墙上\n",
      "9 bottles 啤酒\n",
      "拿一瓶走\n",
      "8 bottles 在啤酒墙上\n",
      "\n",
      "8 bottles 在啤酒墙上\n",
      "8 bottles 啤酒\n",
      "拿一瓶走\n",
      "7 bottles 在啤酒墙上\n",
      "\n",
      "7 bottles 在啤酒墙上\n",
      "7 bottles 啤酒\n",
      "拿一瓶走\n",
      "6 bottles 在啤酒墙上\n",
      "\n",
      "6 bottles 在啤酒墙上\n",
      "6 bottles 啤酒\n",
      "拿一瓶走\n",
      "5 bottles 在啤酒墙上\n",
      "\n",
      "5 bottles 在啤酒墙上\n",
      "5 bottles 啤酒\n",
      "拿一瓶走\n",
      "4 bottles 在啤酒墙上\n",
      "\n",
      "4 bottles 在啤酒墙上\n",
      "4 bottles 啤酒\n",
      "拿一瓶走\n",
      "3 bottles 在啤酒墙上\n",
      "\n",
      "3 bottles 在啤酒墙上\n",
      "3 bottles 啤酒\n",
      "拿一瓶走\n",
      "2 bottles 在啤酒墙上\n",
      "\n",
      "2 bottles 在啤酒墙上\n",
      "2 bottles 啤酒\n",
      "拿一瓶走\n",
      "1 bottle 在啤酒墙上\n",
      "\n",
      "1 bottle 在啤酒墙上\n",
      "1 bottle 啤酒\n",
      "拿一瓶走\n",
      "只剩一瓶了，不能给你了！\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 项目3 P44\n",
    "\n",
    "word=\"bottles\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上\")\n",
    "    print(beer_num,word,\"啤酒\")\n",
    "    print(\"拿一瓶走\")\n",
    "    if beer_num==1:\n",
    "       print(\"只剩一瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num=beer_num-1\n",
    "        if new_num==1:\n",
    "            word=\"bottle\"\n",
    "        print(new_num,word,\"在啤酒墙上\")\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 课后任务：  \n",
    "\n",
    "### 思考，什么是有序的数据（seq type?）  \n",
    "\n",
    "### 预习：数值，字符串  \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
